#!/usr/bin/env python
# -*- conding: utf-8 -*-

import os
import sys
import urllib.request
import json
from pathlib import Path

import PySide6.QtQml
from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtCore import QStringListModel, Qt, QUrl
from PySide6.QtGui import QGuiApplication


if __name__ == '__main__':
    # Set up the application window
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    # qmlFile = Path(__file__).parent / 'view.qml'
    qml_file = Path(__file__).parent / "tableViewDemo.qml"
    engine.load(os.fspath(qml_file.resolve()))
    # view.setResizeMode(QQuickView.SizeRootObjectToView)

    # # Expose the list to the Qml code
    # my_model = QStringListModel()
    # my_model.setStringList(data_list)
    # view.rootContext().setContextProperty("myModel", my_model)

    # Load the QML file
    # qml_file = Path(__file__).parent / "tableViewDemo.qml"
    # view.setSource(QUrl.fromLocalFile(os.fspath(qml_file.resolve())))

    # Show the window
    # if view.status() == QQuickView.Error:
    #     sys.exit(-1)
    # view.show()
    # execute and cleanup
    app.exec()
    # del view
